package twitter.RequestHandler;

import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;



import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import Twitter.RequestSender.RequestSender;

import twitter.Server.ServerType;
import twitter.TwitterLibrary.SocketConfig;
import twitter.TwitterLibrary.Utility;

public class NoticeResponseHandler extends HTTPRequestHandler {
	static Logger logger=Logger.getLogger(NoticeResponseHandler.class);
	
	private RequestSender sender;
	private Utility utility;
	
	private String end;
	private final Lock r;
	private final Lock w;
	public NoticeResponseHandler(ReentrantReadWriteLock rwl,Utility utility) {
		super(rwl,utility);
		r=rwl.readLock();
		w=rwl.writeLock();
		BasicConfigurator.configure();
		this.end="notification";
		
		this.utility=utility;
		sender=new RequestSender(utility);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void parseHttpRequest(String httpInput, PrintWriter httpOutput) {
		// TODO Auto-generated method stub
		String query=httpInput.substring(0, httpInput.indexOf("notification"));
		logger.info("received one primary notice response information");
		//String result=parser.readQueries(query);
		
		//String servers=query.substring(query.indexOf(" "));
		System.out.println("***********In notice response ********primary server receive one notice response message "+query);
		
		utility.readServers(query);
		
		
		
		
		//*************************
	
		

	}

}
